﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Rhino.Mocks;

using SharedGenomics.Workbench.Views;
using SharedGenomics.Workbench.Presenters;
using SharedGenomics.Workbench.Models;
using SharedGenomics.Workbench.PresentationModel;

namespace SharedGenomics.Workbench.Tests.Presenters
{
    [TestClass]
    public class KeggPathwayFrequenciesPresenterTests
    {
        #region Private Method

        private MockRepository mocks;
        private IKeggPathwayFrequenciesModel model;
        private IKeggPathwayFrequenciesView view;

        #endregion

        #region Setup

        [TestInitialize]
        public void Setup()
        {
            this.mocks = new MockRepository();
            this.model = this.mocks.Stub<IKeggPathwayFrequenciesModel>();
            this.view = this.mocks.Stub<IKeggPathwayFrequenciesView>();
        }

        #endregion

        [TestMethod]
        public void ConstructorTest()
        {
            IKeggPathwayFrequenciesView view = this.mocks.StrictMock<IKeggPathwayFrequenciesView>();
            IKeggPathwayFrequenciesModel model = this.mocks.Stub<IKeggPathwayFrequenciesModel>();

            using (this.mocks.Record())
            {
                view.Model = model;
            }

            using (this.mocks.Playback())
            {
                KeggPathwayFrequenciesPresenter p = new KeggPathwayFrequenciesPresenter(view, model);
            }
        }

        [TestMethod]
        public void PathwayFrequenciesTest()
        {
            this.model = this.mocks.StrictMock<IKeggPathwayFrequenciesModel>();

            var pathwayFrequencies = new List<KeggPathwayFrequency>
            {
                new KeggPathwayFrequency("pw1", 1),
                new KeggPathwayFrequency("pw2", 2)
            };

            using (this.mocks.Record())
            {
                this.model.LoadPathwayFrequencies(pathwayFrequencies);
            }

            using (this.mocks.Playback())
            {
                var presenter = this.CreatePresenter();
                presenter.PathwayFrequencies = pathwayFrequencies;
            }
        }

        private KeggPathwayFrequenciesPresenter CreatePresenter()
        {
            return new KeggPathwayFrequenciesPresenter(this.view, this.model);
        }
    }
}
